<%--                                                                       --%>
<%-- Copyright (c) 2003-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import="java.util.*" %>

<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<% String ctxPath = request.getContextPath(); %>

<jsp:useBean id="bpProcessInstanceForm" 
             class="com.broadvision.process.tools.action.process.ProcessInstanceForm"
             scope ="session"/>
<script language="JavaScript" src="<%=request.getContextPath()%>/mt/js/date.js"></script>
<script language="JavaScript" src="<%=request.getContextPath()%>/bp/js/user_popup_funcs.js"></script>
<SCRIPT>
function submitForm(myform)
{
  var iName = myform.elements['instanceName'].value;
  iName = iName.replace(/ /g, "");
  if (iName.length == 0){
    alert('<bean:message key="bp.process.processInstance.alert.instanceName" bundle="bp.messages"/>');
    return false;
  }
  
  iName = myform.elements['instanceManager'].value;
  iName = iName.replace(/ /g, "");
  if (iName.length == 0){
    alert('<bean:message key="bp.process.processInstance.alert.manager" bundle="bp.messages"/>');
    return false;
  } else return true;
}
function setUserAlias(formName, fieldName, fieldValue) {
  var refreshUrl = null;
  setFieldValue(refreshUrl, formName, fieldName, fieldValue);
}
function doReset(myform) {
 myform.action = '<html:rewrite page="/bp/processInstance.do?action=edit"/>';
 myform.submit();
}
function doCancel(myform) {
 myform.action = '<html:rewrite page="/bp/processInstance.do"/>';
 myform.submit();
}
</SCRIPT>
<% java.util.HashMap map= new java.util.HashMap();
   String instanceOid = request.getParameter("instanceOid");
   map.put("instanceOid",instanceOid);
   pageContext.setAttribute("pagetabParam",map);
%>
<html:form action="/bp/processInstanceSave.do">
<input type="hidden" name="instanceOid" value="<%= instanceOid %>">
    <table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message key="bp.process.processInstance.contentArea" bundle="bp.messages"/>">
      <tr>
        <td valign="top" width="100%">
          <div class="pageTitle"><bean:write name="bpProcessInstanceForm" property="instanceName"/></div>
          <%@include file="/mc/common/pagetab.jsp" %>
          <div class="pageSubtitle">
            <span class="left"><bean:message key="bp.process.processInstance.header"  bundle="bp.messages"/></span>
          </div> 
          <table class="dataTable" border="0" cellspacing="0" cellpadding="0" summary="<bean:message key="bp.process.processInstanceSearch.summary" bundle="bp.messages"/>"  width="100%">        
        
            <tr><td class="errorMessage" colspan="2"><html:errors bundle="bp.messages"/></td></tr>
            <tr>
                <td valign="top" nowrap class="label" width="18%"><bean:message key="bp.process.processInstance.processName" bundle="bp.messages"/></td>                
                <td valign="top" wrap class="labelField" width="40%">
                    <bean:write  name="bpProcessInstanceForm"
                          property="processInstance.sspName"/>    
                </td>
            </tr>
            <tr>
                <td valign="top" nowrap class="label" width="18%"><bean:message key="bp.process.processInstance.description" bundle="bp.messages"/></td>                
                <td valign="top" wrap class="labelField" width="40%">
                  <bean:write  name="bpProcessInstanceForm"
                    property="processInstance.ssp.description"/>    
                </td>
            </tr>
            <tr>
                <td valign="top" nowrap class="label" width="18%"><bean:message key="bp.process.processInstance.oid" bundle="bp.messages"/></td>                
                <td valign="top" wrap class="labelField" width="40%">
                    <%= bpProcessInstanceForm.getProcessInstance().getOid() %>    
                </td>
            </tr>
            <tr>
                <td valign="top" nowrap class="label" width="18%"><bean:message key="bp.process.processInstance.launchDate" bundle="bp.messages"/></td>                
                <td valign="top" wrap class="labelField" width="40%">
<bean:write name="bpProcessInstanceForm" property="dates.begin" formatKey="format.datetime.long" bundle="mc.messages"/>
                </td>
            </tr>
            <tr>
                <td valign="top" nowrap class="label" width="18%"><bean:message key="bp.process.processInstance.dueDate" bundle="bp.messages"/></td>                
                <td valign="top" wrap class="labelField" width="40%">
                <bvhtml:date name="bpProcessInstanceForm" property="dueDate"
                   onChangeMonth="onChangeMonth" onChangeYear="onChangeYear" noblank="true"/>
                    <a href="JavaScript:datePopup(
                        '<html:rewrite page="/mt/calendar.do"/>',
                        'bpProcessInstanceForm','dueDate')">
    <img src="<%= ctxPath %>/bp/images/action/calendar.gif"    width="22" height="22" 
    alt="<bean:message key="bp.process.processInstanceSearch.chooseDate"  bundle="bp.messages"/>" 
    border="0" align="absmiddle"/></a>
                </td>
            </tr>
            <tr>
                <td valign="top" nowrap class="label" width="18%"><bean:message key="bp.process.processInstance.completionTime" bundle="bp.messages"/></td>                
                <td valign="top" wrap class="labelField" width="40%">
<bean:write name="bpProcessInstanceForm" property="dates.end" formatKey="format.datetime.long" bundle="mc.messages"/>

                </td>
            </tr>
            <tr>
                <td valign="top" nowrap class="label" width="18%"><bean:message key="bp.process.processInstance.manager" bundle="bp.messages"/></td>                
                <td valign="top" wrap class="labelField" width="40%">
                    <bean:write  name="bpProcessInstanceForm" 
                    property="processInstance.sspDefinition.manager"/>
                </td>
            </tr>
            <tr>
                <td valign="top" nowrap class="label" width="18%"><bean:message key="bp.process.processInstance.instanceName" bundle="bp.messages"/></td>
                <td valign="top" nowrap class="labelField" width="40%"> 
                    <html:text property="instanceName"
                                size="30"
                                maxlength="80"/>
                </td>
            </tr>
            <tr>
                <td valign="top" nowrap class="label" width="18%"><bean:message key="bp.process.processInstance.state" bundle="bp.messages"/></td>
                <td valign="top" nowrap class="labelField" width="40%"> 
                    <html:select  name ="bpProcessInstanceForm" 
                          property = "state"  size="1">                        
                    <html:options
                    name="com.broadvision.process.tools.action.process.ProcessList" 
                    property="mutableProcessInstanceStateValues" 
                    labelName="com.broadvision.process.tools.action.process.ProcessList"
                    labelProperty="mutableProcessInstanceStates" />
                    </html:select>                   
                    
                </td>
            </tr>
            <tr>
                <td valign="top" nowrap class="label" width="18%"><bean:message key="bp.process.processInstance.processManager" bundle="bp.messages"/></td>
                <td valign="top" nowrap class="labelField" width="40%"> 
                    <html:text property="instanceManager" 
                                size="30"
                                maxlength="128"/>
               <input type="button" name="browseUsers" class="pageButton"
              onClick="JavaScript:findUserPopup('<html:rewrite page="/mt/userSearchPopup.do"/>', 'bpProcessInstanceForm', 'instanceManager')"
              value='<bean:message key="button.browse" bundle="bp.messages"/>'>
            </td>
            </tr>
        </table>
      <div class="pageButtonWrap" align="right">
        <input type="button" name="resetData" class="pageButton" 
          onClick="doReset(this.form);" 
          value='<bean:message key="button.reset" bundle="bp.messages"/>'>
        &nbsp;
        <input type="button" name="cancelData" class="pageButton" 
          onClick="doCancel(this.form);" 
          value='<bean:message key="button.cancel" bundle="bp.messages"/>'>
        <input type="submit" class="pageButton" value="<bean:message key="button.save" bundle="bp.messages"/>" onClick="return submitForm(this.form)">
      </div>
        
        </td>
      </tr>
    </table>
  </html:form>
